home *** CD-ROM | disk | FTP | other *** search
/ Champak 86 / (Vol 86) My Disc.iso / Games / pet_1112.swf / scripts / __Packages / EZWardrobeRollOver.as < prev   
Text File  |  2009-04-14  |  2KB  |  66 lines

  1. class EZWardrobeRollOver extends MovieClip
  2. {
  3.    var xp = 0;
  4.    var m = 1;
  5.    var rVelocity = 0;
  6.    var xVelocity = 0;
  7.    var decay = 0.65;
  8.    var k = 0.2;
  9.    function EZWardrobeRollOver()
  10.    {
  11.       super();
  12.       this.rTarget = this._rotation;
  13.       this.xTarget = this._x;
  14.       this.rPos = this._rotation;
  15.       this.xPos = this._x;
  16.       if(this._parent.i == undefined)
  17.       {
  18.          this._parent.i = 0;
  19.       }
  20.       this.index = this._parent.i;
  21.       this._parent.i--;
  22.       if(!this._parent.ezWardrobeRollOvers)
  23.       {
  24.          this._parent.ezWardrobeRollOvers = new Array();
  25.       }
  26.       this._parent.ezWardrobeRollOvers.push(this);
  27.       this.ezWardrobeRollOvers = this._parent.ezWardrobeRollOvers;
  28.       this.onEnterFrame = this.move;
  29.    }
  30.    function move()
  31.    {
  32.       var _loc3_ = (- this.k / this.m) * (this.rPos - this.rTarget);
  33.       this.rVelocity *= this.decay;
  34.       this.rVelocity += _loc3_;
  35.       this.rPos += this.rVelocity;
  36.       this._rotation = this.rPos;
  37.       var _loc2_ = (- this.k / this.m) * (this.xPos - this.xTarget);
  38.       this.xVelocity *= this.decay;
  39.       this.xVelocity += _loc2_;
  40.       this.xPos += this.xVelocity;
  41.       this._x = this.xPos;
  42.    }
  43.    function onRollOver()
  44.    {
  45.       this.onMouseOver();
  46.       for(var _loc3_ in this.ezWardrobeRollOvers)
  47.       {
  48.          if(this._parent.activeClip.index < this.index)
  49.          {
  50.             this.rVelocity = - random(10);
  51.          }
  52.          if(this._parent.activeClip.index > this.index)
  53.          {
  54.             this.rVelocity = random(10);
  55.          }
  56.       }
  57.       this._parent.activeClip = this;
  58.       for(_loc3_ in this.ezWardrobeRollOvers)
  59.       {
  60.          var _loc2_ = this.ezWardrobeRollOvers[_loc3_];
  61.          _loc2_.xTarget = _loc2_.index != this.index ? (_loc2_.index >= this.index ? this._parent.minSpread * (_loc2_.index - 2) + this._parent.maxSpread * 2 : this._parent.minSpread * _loc2_.index) : this._parent.minSpread * (_loc2_.index - 1) + this._parent.maxSpread;
  62.          _loc2_.xTarget += this._parent.xOffset;
  63.       }
  64.    }
  65. }
  66.